package com.banban.user.controller;

import com.banban.user.dto.ConversationLogAddDTO;
import com.banban.user.dto.ConversationLogSuggestDTO;
import com.banban.user.dto.ConversationSelectDTO;
import com.banban.user.dto.SessionInfoSelectDTO;
import com.banban.user.service.ConversationLogService;
import com.banban.user.vo.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author 张振飞
 * @Package com.banban.user.controller
 * @date 2025/4/19 11:15
 */
@RestController
@RequestMapping("/history")
@Slf4j
public class ConversationLogController {

    @Resource
    private ConversationLogService service;

    /**
     * 保持会话记录接口
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public DataResult add(@RequestBody @Valid ConversationLogAddDTO dto) {
        log.info("保持会话记录接口，入参:{}",dto);
        ConversationLogAddVO vo = service.add(dto);
        return DataResult.success(vo);
    }

    /**
     * 对话评价接口
     * @param dto
     * @return
     */
    @PostMapping("/suggest")
    public DataResult suggest(@RequestBody @Valid ConversationLogSuggestDTO dto) {
        log.info("对话评价接口，入参:{}",dto);
        service.suggest(dto);
        return DataResult.success();
    }

    /**
     * 查询用户交互记录
     * @param dto
     * @return
     */
    @PostMapping("/select")
    public DataResult select(@RequestBody @Valid ConversationSelectDTO dto) {
        log.info("查询用户交互记录接口，入参:{}",dto);
        List<ConversationSelectVO> vos = service.select(dto);
        return DataResult.success(vos);
    }

    /**
     * 查询用户会话信息
     * @param dto
     * @return
     */
    @PostMapping("/selectSessionInfo")
    public DataResult selectSessionInfo(@RequestBody @Valid SessionInfoSelectDTO dto) {
        log.info("查询用户交互记录接口，入参:{}",dto);
        IPage<SessionInfoVO> vo = service.selectSessionInfoPage(dto);
        return DataResult.success(vo);
    }

}
